import {  ExecutionContext, NestInterceptor } from "@nestjs/common";
import {
  Observable,
  tap,
  map,
} from "rxjs";


export class Logger2Interceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next): Observable<any> | Promise<Observable<any>> {
    console.log('Before2')
    const now = Date.now() // 获取时间戳
    // console.log(`After1... ${Date.now() - now}`)
    return next.handle().pipe(
      tap({
        next: (val) => {
          console.log(`After2... ${Date.now() - now}ms`, `路由处理函数返回的值 ${val}`)
        }
      })
    )
  }

}
